0a114b
@@ -534,7 +534,13 @@
public class CollectionUtils {
      * That is, iff the cardinality of <i>e</i> in <i>a</i> is
      * equal to the cardinality of <i>e</i> in <i>b</i>,
      * for each element <i>e</i> in <i>a</i> or <i>b</i>.
+     * <p>
+     * <b>Note:</b> from version 4.1 onwards this method requires the input
+     * collections and equator to be of compatible type (using bounded wildcards).
+     * Providing incompatible arguments (e.g. by casting to their rawtypes)
+     * will result in a {@code ClassCastException} thrown at runtime.
      *
+     * @param <E>  the element type
      * @param a  the first collection, must not be null
      * @param b  the second collection, must not be null
      * @param equator  the Equator used for testing equality
@@ -542,8 +548,9 @@
public class CollectionUtils {
      * @throws IllegalArgumentException if the equator is null
      * @since 4.0
      */
-    @SuppressWarnings({ "unchecked", "rawtypes" }) // we don't know the types due to wildcards in the signature
-    public static boolean isEqualCollection(final Collection<?> a, final Collection<?> b, final Equator<?> equator) {
+    public static <E> boolean isEqualCollection(final Collection<? extends E> a,
+                                                final Collection<? extends E> b,
+                                                final Equator<? super E> equator) {
         if (equator == null) {
             throw new IllegalArgumentException("equator may not be null");
         }
@@ -552,7 +559,8 @@
public class CollectionUtils {
             return false;
         }
 
-        final Transformer transformer = new Transformer() {
+        @SuppressWarnings({ "unchecked", "rawtypes" })
+        final Transformer<E, ?> transformer = new Transformer() {
             public EquatorWrapper<?> transform(final Object input) {
                 return new EquatorWrapper(equator, input);
             }
